<template>
    <div class="middle">
        
        <ul>
            <li @click="changeMiddle(index)" v-for="(item,index) in middleArr" :key="index">
                <h3>{{ item.title }}</h3>
                <h4 v-show="item.isShow">{{ item.position }}</h4>
            </li>
        </ul>
    </div>

</template>

<script>
    export default {
        name:"Middle",
        //第一种形式
        // props:["middleArr"],
        //第二种形式
        props:{
            middleArr:{
                type:Array,   //约束传递的数据类型: Array,Object 、String、Number、Boolean 、 Function
                default(){
                    return ["aaa","bbb","ccc"];
                }
            },
            str:{
                type:String ,
                default:"这个是默认数据",  
                validator(value){
                    return ["王宁","王凡","王一凡"].includes(value);
                }
            },
            num:{
                type:Number,
                required:true,   //必须传递
                validator(value){   //自定义验证数据
                    return value >= 18 && value <= 65 ? true : false;
                }

            },
            changeMiddle:{
                type:Function,
                required:true
            }
        },
        
       
       
    }
</script>

<style scoped>
.middle ul{
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
}

.middle ul li{
    width: 200px;
    height: 200px;
    text-align: center;
    line-height: 100px;
    border: 1px dashed darkblue;
    margin: 20px;
    cursor: pointer;
}

.middle ul li:hover{
    background: gainsboro;
}
</style>